from pydantic import BaseModel, Field
from typing import List, Optional


class BaseMiniSettings(BaseModel):
    name: str = Field(..., description="配置名称", example="配置名称1")
    set_value: str = Field("", description="配置值")
    is_active: Optional[bool] = True

class MiniSettingsCreate(BaseMiniSettings):
    ...

class MiniSettingsUpdate(BaseMiniSettings):
    id: int
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})

class BaseMiniAlert(BaseModel):
    name: str = Field("", example="名称1")
    order: int = Field(0)
    cover: Optional[str]  = Field(None)
    start_time: Optional[str] = Field("2024-01-01 00:00:00")
    end_time: Optional[str] = Field("2024-01-01 00:00:00")
    go_type: Optional[int] = Field(0)
    go_url: Optional[str] = Field(None)
    is_active: Optional[bool] = True

class MiniAlertCreate(BaseMiniAlert):
    ...

class MiniAlertUpdate(BaseMiniAlert):
    id: int
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})

class BaseMiniTopic(BaseModel):
    name: str = Field("", example="名称1")
    order: int = Field(0)
    content: Optional[str] = Field(None)
    is_active: Optional[bool] = True

class MiniTopicCreate(BaseMiniTopic):
    content: Optional[list] = None

class MiniTopicUpdate(BaseMiniTopic):
    id: int
    content: Optional[list] = None
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})

class BaseMiniFav(BaseModel):
    user_id: int = Field(0)
    type: int = Field(0)
    type_id: int = Field(0)

class MiniFavCreate(BaseMiniFav):
    ...

class MiniFavUpdate(BaseMiniFav):
    id: int
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})


class CosPath(BaseModel):
    path: str = Field(..., description="图片列表逗号拼接")

class BaseMiniLike(BaseModel):
    user_id: int = Field(0)
    type: int = Field(0)
    type_id: int = Field(0)

class MiniLikeCreate(BaseMiniLike):
    ...

class MiniLikeUpdate(BaseMiniLike):
    id: int
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})

class BaseMiniLayers(BaseModel):
    user_id: Optional[int] = Field(0)
    title: Optional[str] = Field("")
    content: Optional[str] = Field("")
    images: Optional[str] = Field(None)
    praise_count: Optional[int] = Field(0)
    review_count: Optional[int] = Field(0)
    collect_count: Optional[int] = Field(0)
    comment_at: Optional[str] = Field("2024-01-01 00:00:00")
    status: Optional[int] = Field(0)

class MiniLayersCreate(BaseMiniLayers):
    images: Optional[list] = None

class MiniLayersUpdate(BaseMiniLayers):
    id: int
    images: Optional[list] = None
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})

class BaseMiniComment(BaseModel):
    user_id: Optional[int] = Field(0)
    type: int = Field(0)
    type_id: int = Field(0)
    content: Optional[str] = Field("")
    comment_id: int = Field(0)
    praise_count: Optional[int] = Field(0)
    status: Optional[int] = Field(0)

class MiniCommentCreate(BaseMiniComment):
    ...

class MiniCommentUpdate(BaseMiniComment):
    id: int
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})